<?php

class ti_date
{
	function days_in_month($year,$month)
	{
		return $numberOfDays = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
	}
	
	function cal_start_day($year,$month,$return_as_epoch=true)
	{
		global $ti;
		$start_day = gmmktime(0,0,0,$month,1,$year);
		$start_day_number = date("w",$start_day);
		return $start_day - (86400 * $start_day_number);
	}
	
	function cal_end_day($year,$month,$return_as_epoch=true)
	{
		global $ti;
		$days_in_month = ti_date::days_in_month($year,$month);
		$end_day = gmmktime(0,0,0,$month,$days_in_month,$year);
		$end_day_number = date("w",$end_day);
		#$ti->log('this ends on: '.$end_day_number);
		return $end_day + ((6 - $end_day_number) * 86400);
	}
}

?>